<?php require_once('../Connections/locale.php'); ?>
<?php
mysql_select_db($database_locale, $locale);
$query_indirizzi = $_POST['query'];
$indirizzi = mysql_query($query_indirizzi, $locale) or die(mysql_error());
$row_indirizzi = mysql_fetch_assoc($indirizzi);
$totalRows_indirizzi = mysql_num_rows($indirizzi);
?>
<? 


//echo $query_indirizzi;


//require_once('../includes/html2fpdf.php');

//error_reporting(1);






// activate Output-Buffer:


//ob_start(); 

//$pdf = new HTML2FPDF('Landscape');
//$pdf->DisableTags();
//$pdf->Orientation('Landscape');

$righe = 1;
$colonne = 1;


//echo $query;
 
$xml_output="";

$xml_output .="<table border=1 width=100% height=100%>";
$xml_output .="<tr height=119px>";
//$pdf->AddPage();

do { 




if ($colonne > 2) {
	$colonne = 1;
	$righe += 1;
	$xml_output .="</tr>";
	$xml_output .="<tr height=219px>";
}

$xml_output .="<td width=300px height=250px>";
$xml_output .="<center><strong>".$row_indirizzi['nominativo']."</strong><br>";
$xml_output .=$row_indirizzi['indirizzo']."<br>";
$xml_output .=$row_indirizzi['cap']." ".$row_indirizzi['nome_citta']." (".$row_indirizzi['sigla_provincia'].") <br>";
$xml_output .=$row_indirizzi['nome_stato']."<br>";
$xml_output .="</center></td>";

$colonne += 1;

if ($righe > 8) {
	$colonne = 1;
	$righe = 1;
	$xml_output .= "</table>";
	//$pdf->WriteHTML($xml_output);
	//$pdf->AddPage();
	$xml_output .=$messaggio_temp."<PAGE>";
	$xml_output .="<table border=1>";
}







 } while ($row_indirizzi = mysql_fetch_assoc($indirizzi)); 

if ($colonne < 2) {
	$xml_output .="<td colspan=".(4-$colonne+1).">&nbsp;</td></tr></table>";
}
if ($righe < 8) {
	$xml_output .="</tr></table>";
}



//echo $xml_output;


header("Content-Disposition:attachment;filename=etichette.rtf "); 



?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body>
 
	<?php echo ($xml_output); ?>  
 
</body>
</html> 
 
<?php
mysql_free_result($indirizzi);
?>